package com.model.defaults.tabsheet;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;



public class ModelDefaultTabsheetUser {

    public static void createTabsheetItemsUserOpen ( Session session,
                                                     Map <String, UserContextName> userContexts ) {

        /*
         * BrowseAdministration
         */

        TabSheetItem pojo = null;
        UserContextName contextName_1 = null;
        ActionScript actionScript = null;
        KeyValue actionScriptParam = null;


        actionScript = new ActionScript();
        actionScriptParam = new KeyValue("p3", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScriptParam = new KeyValue("t1", "selectedTab=1");
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScript.setActionScriptText("UserInfo?{p3}&{t1}");
        actionScript.setActionScriptType("servlet");

        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_USERINFO);
        pojo = new TabSheetItem();
        pojo.setName("Description");
        pojo.setCaption("Description");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/tabUserInfo.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_USERINFO);
        pojo.setIsDefault(true);
        pojo.setActionScript(actionScript);
        session.save(pojo);


        actionScript = new ActionScript();

        actionScriptParam = new KeyValue("p3", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScriptParam = new KeyValue("t1", "selectedTab=2");
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScript.setActionScriptText("UserInfo?{p3}&{t1}");
        actionScript.setActionScriptType("servlet");

        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_USERINFO);
        pojo = new TabSheetItem();
        pojo.setName("Activity");
        pojo.setCaption("Activity");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/tabUserActivity.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_USERINFO);
        pojo.setActionScript(actionScript);
        session.save(pojo);

    }

}
